package com.zougen202301180355.restaurant.service.impl;

import com.zougen202301180355.restaurant.mapper.MenuItemsMapper;
import com.zougen202301180355.restaurant.pojo.MenuItem;
import com.zougen202301180355.restaurant.service.MenuItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 邹根
 * 菜单服务实现类
 */
@Service
@Transactional
public class MenuItemsServiceImpl implements MenuItemsService {

    @Autowired
    private MenuItemsMapper menuItemsMapper;

    @Override
    public void addMenuItem(MenuItem menuItem) {
        menuItemsMapper.insert(menuItem);
    }

    @Override
    public void deleteMenuItem(Integer id) {
        menuItemsMapper.delete(id);
    }

    @Override
    public void updateMenuItem(MenuItem menuItem) {
        menuItemsMapper.update(menuItem);
    }

    @Override
    public MenuItem getMenuItemById(Integer id) {
        return menuItemsMapper.selectById(id);
    }

    @Override
    public List<MenuItem> getAllMenuItems() {
        return menuItemsMapper.selectAll();
    }
}
